#ifndef SONG_MANIP_H_
#define SONG_MANIP_H_

#include <stdio.h>
#include <stdlib.h>

#include "rtc.h"
#include "music.h"
#include "GQueue.h"

/** @defgroup songmanip SongManip
 * @{
 *
 * Utilities for manipulating songs.
 */
 
_go32_dpmi_seginfo old_rtc_irq;
GQueue* music_queue;
 Song* bgm;
 
 
void rtc_isr(void);

void load_notes_queue();

void song_pre_load_queue(int n_notes);

void song_init(char* songname);

void song_finalize();

/** Allocates memory for the song and loads it with the contents
of "filename" file (properly formatted).
returns NULL on error.
*/
Song* song_load(char* filename);


/** Modifies song speed. Assumes a "beats_measure" beats
measure (given by "dur" on "Note" struct) and "bpm" beats
per minute.
*/
void set_bpm(Song* s, int beats_measure, float bpm);


/** Modifies song speed from a beats per minute "old_bpm"
to "new_bpm".
*/
void modify_bpm(Song* s, float old_bpm, float new_bpm);


/** Modifies song pitch. Rises all notes' pitch by
"halfsteps_up" semitones. Negative values decrease song
pitch.
*/
void modify_pitch(Song* s, int halfsteps_up);


/** Saves a song in the file "filename" properly formatted.
*/
void song_save(Song* s, char* filename);


/** Deletes a song, releasing all resources used by it.
 */
void song_delete(Song* s);

/** @} end of songmanip */
	
#endif
